import Vue from 'vue'
import VueRouter from 'vue-router'

Vue.use(VueRouter)

const originalPush = VueRouter.prototype.push;

VueRouter.prototype.push = function push(location){
  return originalPush.call(this, location).catch(err => err)
}

const routes = [
  {
    path: '*',
    redirect: '/404'
  },
  {
    path: '/404',
    component: () => import('../pages/404.vue')
  },
  {
    path: '/login-in',
    name: 'login-in',
    component: () => import('../pages/LoginIn'),
  },
  {
    path: '/sign-up',
    name: 'sign-up',
    component: () => import('../pages/SignUp')
  },
  {
    path: '/',
    name: 'home',
    component: () => import('../pages/Home')
  },
  {
    path: '/song-list',
    name: 'song-list',
    component: () => import('../pages/SongList')
  },
  {
    path: '/my-video',
    name: 'my-video',
    component: () => import('../pages/MyVideo')
  },
  {
    path: '/my-approve',
    name: 'my-approve',
    component: () => import('../pages/MyApprove')
  },
  {
    path: '/song-list-album/:id',
    name: 'song-list-album',
    component: () => import('../pages/SongListAlbum')
  },
  {
    path: '/singer',
    name: 'singer',
    component: () => import('../pages/Singer')
  },
  {
    path: '/singer-album/:id',
    name: 'singer-album',
    component: () => import('../pages/SingerAlbum')
  },
  {
    path: '/lyric/:id',
    name: 'lyric',
    component: () => import('../pages/Lyric')
  },
  {
    path: '/video/:videoId',
    name: 'videoDetail',
    component: () => import('../pages/VideoDetail')
  },
  {
    path: '/video/:videoId/edit',
    name: 'videoEdit',
    component: () => import('../pages/VideoEdit')
  },
  {
    path: '/search',
    name: 'search',
    component: () => import('../pages/Search')
  },
  {
    path: '/setting',
    name: 'setting',
    component: () => import('../pages/Setting')
  },
  {
    path: '/user/:userId',
    name: 'userDetail',
    component: () => import('../pages/UserDetail')
  },
  {
    path: '/upload',
    name: 'upload',
    component: () => import('../pages/Upload')
  }
]

const router = new VueRouter({
  mode: 'history',
  base: process.env.BASE_URL,
  routes
})


export default router
